package com.eos.control.action.customer;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.eos.business.service.SysCustomerBusinessService;
import com.eos.common.tool.ConstantTool;
import com.eos.control.action.base.AbstractBaseAction;
import com.eos.orm.mybatis.model.SysCustomerLink;
import com.hf.utils.PaginationBean;

public class CustomerLinkListAction extends AbstractBaseAction {
	private static final long serialVersionUID = 8740700710281919982L;
	private Integer customerId;
	private String linkName;
	private Integer pageNum;
	private Integer numPerPage;
	private List<SysCustomerLink> customerLinkList;
	private Integer totalCount;
	
	public Integer getCustomerId() {
		return customerId;
	}

	public void setCustomerId(Integer customerId) {
		this.customerId = customerId;
	}

	public String getLinkName() {
		return linkName;
	}

	public void setLinkName(String linkName) {
		this.linkName = linkName;
	}

	public Integer getPageNum() {
		return pageNum;
	}

	public void setPageNum(Integer pageNum) {
		this.pageNum = pageNum;
	}

	public Integer getNumPerPage() {
		return numPerPage;
	}

	public void setNumPerPage(Integer numPerPage) {
		this.numPerPage = numPerPage;
	}

	public List<SysCustomerLink> getCustomerLinkList() {
		return customerLinkList;
	}

	public Integer getTotalCount() {
		return totalCount;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String execute()  {
		try {
			SysCustomerBusinessService scbs = new SysCustomerBusinessService();
			Map<String, String> map = new HashMap<String, String>();
			if(numPerPage == null || numPerPage.intValue() ==0) numPerPage = PAGE_SIZE;
			if(pageNum == null || pageNum.intValue() == 0) pageNum = 1;
			map.put("page_size", numPerPage+"");
			map.put("cur_page", pageNum+"");
			map.put("link_name", linkName);
			map.put("status", ConstantTool.STATUS_OK);
			map.put("deal_flag", ConstantTool.DEAL_FALG_OK);
			map.put("customer_id", String.valueOf(customerId));
			map.put("table_name", "sys_customer_link");
			PaginationBean pageBean = scbs.getSysCustomerLinkList(map);
			totalCount = null != pageBean ? pageBean.getMaxcount() : 0;
			customerLinkList =  (null != pageBean ? (List<SysCustomerLink>)pageBean.getResultList() : null);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return SUCCESS;
	}
}
